# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=groff
pkgver=1.22.4
pkgrel=1
pkgdesc="GNU troff text-formatting system"
url="https://www.gnu.org/software/groff/groff.html"
arch="all"
license="GPL-3.0-or-later"
makedepends="perl bison zlib-dev texinfo"
checkdepends="diffutils"
subpackages="$pkgname-doc"
source="https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz
	site.tmac
	"

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--without-x \
		--disable-rpath
	# work around parallel build issue
	make arch/misc && make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/lib/charset.alias
	rmdir -p "$pkgdir"/usr/lib 2>/dev/null || true
	for f in man mdoc; do
		cat ${srcdir}/site.tmac >> \
			${pkgdir}/usr/share/groff/site-tmac/${f}.local
	done

	# Prevent conflict with mandoc-doc
	rm -f "$pkgdir"/usr/share/man/man1/soelim.1 \
		"$pkgdir"/usr/share/man/man7/roff.7
}

sha512sums="1c42d3cd71efaf067b5850945d9097fa1f0fadd5e2b6ba7446bd9d4f439fe1ad058e4ddb0d4e0f503682137dfc7c822944ce1e3e5cf981673f8ba197ea77126d  groff-1.22.4.tar.gz
f6818f17fdfc76bfecc90c225b0173dabe2be0fe04058869d09556a22cb2c44545a51fa668f69d1843fe2d2344b978367da61189d65b27eed39dcbb9d7a12309  site.tmac"
